﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Zz
{
    class DBHelper1
    {
        public static string connStr = "server=.;database=Admin;Integrated Security=true";

        public static SqlDataReader select(string sql)
        {
            SqlConnection sqlConnection = new SqlConnection(connStr);

            sqlConnection.Open();

            SqlCommand amd = new SqlCommand(sql, sqlConnection);

            return amd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
        }
        public static bool Ng(string sql)
        { 
            bool result = false;
            //连接
            SqlConnection conn = new SqlConnection(connStr);
            //命令对象
            SqlCommand adr = new SqlCommand(sql, conn);
            //打开数据库
            conn.Open();

            int num = adr.ExecuteNonQuery();

            if (num > 0)
            {
                result = true;
            }
            conn.Close();
            return result;
        }
    }
}
